package com.sjgl.esdn.controller;


import com.sjgl.esdn.domain.AjaxResultESDN;
import com.sjgl.esdn.domain.entity.Dept;
import com.sjgl.esdn.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 部门控制器
 *
 * @author 缪恒铭
 * @date 2022/08/18
 */
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    DeptService deptService;

    /**
     * 获得部门名字列表
     *
     * @return {@link AjaxResultESDN}
     */
    @GetMapping("/nameList")
    public AjaxResultESDN getDeptNameList() {
        AjaxResultESDN ajax = AjaxResultESDN.success();
        ajax.put(AjaxResultESDN.DATA_TAG, deptService.getDeptNameList());
        return ajax;
    }

    //创建部门


    /**
     * 获取部门树列表
     */
    @GetMapping("/deptTree")
    public AjaxResultESDN deptTree(Dept dept)
    {
        return AjaxResultESDN.success(deptService.selectDeptTreeList(dept));
    }
}
